package org.hawk.gwt.ppc.introspection;

import java.util.Collection;

import org.hawk.gwt.ppc.parser.ClassDescriptor;
import org.hawk.gwt.ppc.parser.CompilationUnitDescriptor;
import org.hawk.gwt.ppc.utils.PreprocessorException;

/**
 * Contains and manages already parsed compilation units.
 * Invokes parser when necessary to lazily parse classes on demand.
 * 
 * @author alex.bereznevatiy@gmail.com
 *
 */
public interface SourcesRepository {
	
	/**
	 * Searches for class by its name.
	 * @param className
	 * @return parsed class
	 * @throws PreprocessorException in case of parsing fails or 
	 * class cannot be found.
	 */
	ClassDescriptor requireClass(String className) throws PreprocessorException;
	
	/**
	 * Searches for class by its name.
	 * @param className
	 * @return parsed class or <code>null</code> if class not found
	 * @throws PreprocessorException in case of parsing fails.
	 */
	ClassDescriptor findClass(String className) throws PreprocessorException;
	
	/**
	 * @param compilationUnitName
	 * @return parsed compilation unit with name specified.
	 * @throws PreprocessorException in case of parsing fails or compilation unit cannot be found
	 */
	CompilationUnitDescriptor findCompilationUnit(String compilationUnitName) throws PreprocessorException;
	
	/**
	 * Mark the class with name specified as changed.
	 * @param className
	 */
	void markChanged(String className);
	
	/**
	 * @return collection of class names that were changed by the preprocessor.
	 */
	Collection<String> getChangedClasses();

	/**
	 * @param clazz
	 * @return <code>true</code> if class with name passed has been marked as changed.
	 */
	boolean isChanged(String clazz);
}
